<script>
  function deepCopy(data) {
    if (typeof data !== 'object') {
      return data
    }
    let result = Array.isArray(data) ? [] : {}
    if (Array.isArray(result)) {
      for (i = 0; i < data.length; i++) {
        result.push(deepCopy(data[i]))
      }
    } else {
      for (let key in data) {
        result[key] = deepCopy(data[key])
      }
    }
    return result
  }
  let arr = [1, 2, { name: '长江' }]
  newArr = deepCopy(arr)
  newArr[2].name = '二桥'
  console.log(arr)
  console.log(newArr)
</script>
